<template>
  <el-pagination
    background
    @size-change="handleSizeChange"
    @current-change="handleCurrentChange"
    :current-page="currentPage"
    :page-sizes="pageSizes"
    :page-size="pageSize"
    :layout="layout"
    :total="total">
  </el-pagination>
</template>

<script>
import mixins from './mixins'
export default {
  name: 'index',
  title: '用用分页组件',
  mixins: [mixins],
  props: {
    total: {
      type: Number,
      default: 0
    },
    page: {
      type: Number,
      default: 1
    },
    size: {
      type: Number,
      default: 20
    }
  },
  data () {
    return {
      pageSizes: [10, 20, 30, 40],
      layout: 'total, sizes, prev, pager, next, jumper'
    }
  },
  methods: {
    // 每页条数
    handleSizeChange (count) {
      this.$emit('pageSize', count)
      this.$emit('size', count)
    },
    // 当前页
    handleCurrentChange (count) {
      this.$emit('page', count)
    }
  }
}
</script>

<style scoped lang="scss">
.el-pagination{
  text-align: center;
  padding: 20px 0;
}
</style>
